import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:lishopflu/base/controller_import.dart';
//import 'package:provider/provider.dart';
import 'base/base_import.dart';
import 'global/my_theme_data.dart';
import 'global/theme_colors.dart';
import 'global/theme_provide.dart';
import 'utils/li_log.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  //顶部状态栏透明
  SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle(statusBarColor: Colors.transparent)
  );
  // 强制竖屏
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown
  ]);

  LiLog.init(isDebug: true, title: 'LiShop',);
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Flutter Demo',
      theme: MyThemeData.appTheme(THColors.themeColor['green']),
      //home: MyHomePage(title: 'Flutter Demo Home Page'),
      debugShowCheckedModeBanner: false,// 在选中模式下打开一个小的“DEBUG”横幅
      initialRoute: AppPages.SPLASH,// 显示的第一个路由的名称,可以代替home
      getPages: AppPages.routes,
      unknownRoute: AppPages.unknownRoute,
      defaultTransition: Transition.fade,
    );
    /*return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_)=>ThemeProvide())
      ],
      child: Consumer<ThemeProvide>(
        builder: (_context,theme,_){
          return GetMaterialApp(
            title: 'Flutter Demo',
            theme: MyThemeData.appTheme(_themeColor(theme)),
            //home: MyHomePage(title: 'Flutter Demo Home Page'),
            debugShowCheckedModeBanner: false,// 在选中模式下打开一个小的“DEBUG”横幅
            initialRoute: AppPages.SPLASH,// 显示的第一个路由的名称,可以代替home
            getPages: AppPages.routes,
            unknownRoute: AppPages.unknownRoute,
            defaultTransition: Transition.fade,
          );
        },
      ),
    );*/
  }

  _themeColor(ThemeProvide theme/*, String type*/){
    String pause = theme.themeIndex;
    return THColors.themeColor[pause != null ? pause: 'green']/*[type]*/;
  }
}